package com.wandian.cqcsk.mvvm.mine.invite.editinvite;

import android.os.Bundle;
import android.view.View;

import androidx.databinding.DataBindingUtil;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.StatusBarUtils;
import com.mylib.libcore.utils.ToastUtil;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.cqcsk.R;
import com.wandian.cqcsk.databinding.ActivityEditInviteBinding;
import com.wandian.cqcsk.databinding.ActivityMyWalletBinding;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description 填写邀请
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_EDIT_INVITE)
public class EditInviteActivity extends BaseMVVMActivity<EditInviteActivityViewModel> {
    private ActivityEditInviteBinding dataBinding;

    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_edit_invite);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initViewData();
        initClink();
    }



    private void initViewData(){
        //设置状态颜色和字体黑色
        StatusBarUtils.with(this,false)
                .setIsActionBar(false)
                .clearActionBarShadow()
                .setDrawable(getResources().getDrawable(com.mylib.libcore.R.drawable.sys_color))
                .init();
        dataBinding.bindSysToolBar.toolBarTvTitle.setText("填写推荐人");

    }
    private void initClink(){
        dataBinding.bindSysToolBar.toolBarIvBack.setOnClickListener(v -> {
            finishhideSoftBoard();
            finish();
        });

        dataBinding.tvBtn.setOnClickListener(v -> {
            finishhideSoftBoard();
            if(UIUtils.isEmpty(dataBinding.etInvite.getText())){
                ToastUtil.show("请填写推荐人邀请码");
                return;
            }
            mViewModel.editInvite(dataBinding.etInvite.getText().toString().trim());
        });

    }

    @Override
    protected void onDestroy() {
        finishhideSoftBoard();
        super.onDestroy();
    }
}
